package models

import (
	"time"
	"github.com/astaxie/beego/orm"
)

//积分兑换

type PointCommit struct {
	Id         int64
	Point      int       `ht:"list;name(交易积分额度)"`
	FromUser   int       `ht:"list;search;name(消费积分者编号)"`
	ToUser     int       `ht:"list;name(接受积分者编号)"`
	CommitType int       `ht:"list;subclass([{\"Num\":0,\"Name\":\"用户向商家缴纳\"},{\"Num\":1,\"Name\":\"商家向服务台缴纳\"},{\"Num\":2,\"Name\":\"清算\"}]);name(类型)"`
	CommitTime time.Time `ht:"list;name(消费时间)"`
	Addition   string    `ht:"list;name(备注)"`
}

func init() {
	orm.RegisterModel(new(PointCommit))
}
func (*PointCommit) TableName() string {
	return "point_commit"
}

func (*PointCommit) FN_Id() string {
	return "Id"
}
func (*PointCommit) FN_Point() string {
	return "Point"
}
func (*PointCommit) FN_FromUser() string {
	return "FromUser"
}
func (*PointCommit) FN_ToUser() string {
	return "ToUser"
}
func (*PointCommit) FN_CommitType() string {
	return "CommitType"
}
func (*PointCommit) FN_CommitTime() string {
	return "CommitTime"
}
func (*PointCommit) FN_Addition() string {
	return "Addition"
}

func PointCommitInsert(pointcommit *PointCommit) error {
	o := orm.NewOrm()
	_, err := o.Insert(pointcommit)
	return err
}
